<template>
	<view class="content">
		<Search></Search>
		<view class="list-content">
			<view class="list-col">
				<navigator hover-class="none" :url="'/pages/Vlog/detail?id='+item.id" v-for="(item,index) in list.colA"
					:key="item.id" class="list-item">
					<view class="photo-block">
						<image mode="widthFix" class="photo" :src="item.imgList[0].imgUrl"></image>
						<view v-if="item.position" class="position">
							<view class="iconfont icon-weizhi"></view>{{item.position}}
						</view>
					</view>
					<view class="title">{{item.title}}</view>
					<view class="user">
						<image class="user-photo" :src="item.customer.faceUrl"></image>
						<view class="user-name">{{item.customer.notName}}</view>
						<view class="iconfont icon-zan"></view>
						<view class="view-count">{{item.fabulous}}</view>
					</view>
				</navigator>
			</view>
			<view class="list-col">
				<navigator hover-class="none" :url="'/pages/Vlog/detail?id='+item.id" v-for="(item,index) in list.colB"
					:key="item.id" class="list-item">
					<view class="photo-block">
						<image mode="widthFix" class="photo" :src="item.imgList[0].imgUrl"></image>
						<view v-if="item.position" class="position">
							<view class="iconfont icon-weizhi"></view>{{item.position}}
						</view>
					</view>
					<view class="title">{{item.title}}</view>
					<view class="user">
						<image class="user-photo" :src="item.customer.faceUrl"></image>
						<view class="user-name">{{item.customer.notName}}</view>
						<view class="iconfont icon-zan"></view>
						<view class="view-count">{{item.fabulous}}</view>
					</view>
				</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getListApi
	} from '@/api/vlog.js'
	export default {
		data() {
			return {
				list: {
					colA: [],
					colB: []
				}
			}
		},
		methods: {
			getList() {
				getListApi({
					page: 0,
					limit: 0
				}).then((res) => {
					if (res.code == 1) {
						this.list.colA = res.dataA
						this.list.colB = res.dataB
					} else {
						uni.showToast({
							title: '加载失败',
							mask: true,
						})
					}
				}).catch((res) => {
					uni.hideLoading();
					uni.showToast({
						title: '加载失败',
						mask: true,
					})
				})
			},
		},
		onLoad() {
			uni.$on('getSearchInput', (e) => {
				this.title = e;
			})
		},
		onShow() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx;
		width: 100%;

		.list-content {
			width: 100%;
			display: flex;
			flex-direction: row;
			margin-top: 20rpx;
			padding-bottom: 20rpx;

			.list-col {
				width: calc(50% - 10rpx);
				margin-right: 20rpx;
				display: flex;
				flex-direction: column;

				.list-item {
					width: 100%;
					display: flex;
					flex-direction: column;
					margin-bottom: 20rpx;

					.photo-block {
						width: 100%;
						position: relative;
						display: flex;
						flex-direction: row;

						.photo {
							border-radius: 20rpx;
							width: 100%;
						}

						.position {
							position: absolute;
							width: 100%;
							bottom: 20rpx;
							left: 20rpx;
							color: #fff;
							font-size: 24rpx;
							display: flex;

							.iconfont {
								margin-right: 10rpx;
							}
						}
					}

					.title {
						font-size: 30rpx;
						font-weight: bold;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
						overflow: hidden;
						margin-top: 16rpx;
					}

					.user {
						margin-top: 10rpx;
						display: flex;
						flex-direction: row;
						width: 100%;
						align-items: center;

						.user-photo {
							width: 40rpx;
							height: 40rpx;
							margin-right: 10rpx;
							border-radius: 50%;
						}

						.user-name {
							font-size: 24rpx;
							color: $color-secondary-text;
							flex-grow: 1;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.view-count {
							font-size: 24rpx;
							color: $color-secondary-text;
						}

						.iconfont {
							margin-right: 10rpx;
							color: $color-secondary-text;
							font-size: 28rpx;
						}

						.iconfont.icon-zanxuanzhong {
							color: red;
						}

					}
				}

				.list-item:last-child {
					margin-bottom: 0;
				}
			}

			.list-col:last-child {
				margin-right: 0;
			}
		}
	}
</style>
